﻿var qc_dau_count:Number=0;
var qc_cuoi_count:Number=0;
Stage.scaleMode="noScale";
var fixed_width:Number=110;
var fixed_height:Number=75;
video_region._x=0;
video_region._y=0;
Stage.addListener(this);
var ini_width:Number=450;
var ini_height:Number=370;
var related_film_can_display:Number=3;
var first_related_film_position_x:Number=0;
var first_related_film_position_y:Number=0;

_root.control_region.played_ins._width=0;
var mouse_moving:Boolean=false;

_root.control_region._x =- (Stage.width-ini_width)/2;	

var video_start_tween_height:Number=Stage.height-control_region._height-110;
var video_end_tween_height:Number=video_end_height+control_region._height/2-24;

var video_start_tween_y:Number=Stage.height/2-20;
var video_end_tween_y:Number=Stage.height/2-3;

var video_start_tween_x:Number=Stage.height/2-20;
var video_end_tween_x:Number=Stage.height/2-3;

var video_start_tween_width:Number=Stage.width-50;
var video_end_tween_width:Number=video_end_width;

var video_end_width:Number;
var video_end_height:Number;

var width_vary:Number= 80;
var height_vary:Number=60;
var video_width_start:Number = _root.video_region.my_video._width;
var video_width_end:Number = _root.video_region.my_video._width - width_vary;
var video_height_start:Number = _root.video_region.my_video._height;
var video_height_end:Number = _root.video_region.my_video._height - height_vary;
var video_x_start:Number = _root.video_region.my_video._x;
var video_x_end:Number = _root.video_region.my_video._x + width_vary/2;
var video_y_start:Number = _root.video_region.my_video._y;
var video_y_end:Number = _root.video_region.my_video._y + height_vary/2;

if(Stage.width*3>Stage.height*4)
{
	// Choan het chieu cao
	video_end_height=Stage.height;			
	video_end_width=Stage.height*4/3;
	control_end_tween_y = (Stage.height+ini_height)/2-5;	
	control_start_tween_y = (Stage.height+ini_height)/2- control_region._height;		
	video_height_start	=Stage.height;	
	video_height_end	= Stage.height-_root.control_region._height;
	video_y_start = -(Stage.height-ini_height)/2;// - video_height_start/2;
	video_y_end	  = -(Stage.height-ini_height)/2 ;
	video_width_start = Stage.height*4/3;
	video_width_end = video_height_end * 4/3;
	video_x_start = -(Stage.width-ini_width)/2 + (Stage.width-video_width_start)/2;
	video_x_end = video_x_start+ (video_width_start-video_width_end)/2;	
}
else
{
	//Choan het chieu rong
	video_end_width=Stage.width;
	video_end_height=Stage.width*3/4;				
	if(video_end_height+control_region._height>Stage.height)
	{
		control_end_tween_y = (Stage.height+ini_height)/2-5;	
		control_start_tween_y = -(Stage.height-ini_height)/2+ Stage.height-control_region._height;//(Stage.height+ini_height)/2- control_region._height;		
		video_height_start	= video_end_height;	
		video_height_end	= Stage.height-_root.control_region._height;
		
		video_y_start = -(Stage.height-ini_height)/2 ;
		video_y_end = video_y_start ; 
		video_width_start = Stage.width;
		video_width_end = video_height_end * 4/3;		
		video_x_start = -(Stage.width-ini_width)/2 + (Stage.width-video_width_start)/2;
		video_x_end = video_x_start+ (video_width_start-video_width_end)/2;			
	}
	else
	{
		control_end_tween_y = (Stage.height+ini_height)/2-5;	
		control_start_tween_y = -(Stage.height-_root.ini_height)/2+ Stage.height-control_region._height;//(Stage.height+ini_height)/2- control_region._height;		
		video_height_start	= video_end_height;	
		video_height_end	= video_height_start;
		
		video_y_start = -(Stage.height-_root.ini_height)/2 + (Stage.height-video_height_start)/2;
		video_y_end = video_y_start - control_region._height/2; 
		video_width_start = Stage.width;
		video_width_end = video_width_start;		
		video_x_start = -(Stage.width-ini_width)/2 + (Stage.width-video_width_start)/2;
		video_x_end = video_x_start+ (video_width_start-video_width_end)/2;	
	}
	
}	
	my_related_movie0._x = -(Stage.width-ini_width)/2+(Stage.width-my_related_movie0)/2;
	my_related_movie0._y = -(Stage.height-ini_height)/2+50;
	
	video_region.my_video._x=-video_region.my_video._width/2;
	video_region.my_video._y=-video_region.my_video._height/2;
	_root.control_region._width=Stage.width;
	
	_root.control_region.replay_ins._width *= (ini_width/Stage.width);;	
	_root.control_region.pause_button_ins._x = 25 /(Stage.width/ini_width)  ;	
	_root.control_region.play_button_ins._x  = _root.control_region.pause_button_ins._x;
	_root.control_region.replay_ins._x = _root.control_region.pause_button_ins._x + 25 /(Stage.width/ini_width) ;		
	_root.control_region.replay_ins_dim._x = _root.control_region.replay_ins._x ;	
	_root.control_region.time_region._x = _root.control_region.replay_ins_dim._x +20; 	
	
	_root.control_region.logo._width *= (ini_width/Stage.width);			
	_root.control_region.logo._x = ini_width-_root.control_region.logo._width;	

	_root.control_region.thanh_truot2._width *= ini_width/Stage.width;	
	
	_root.control_region.share._x = _root.control_region.logo._x- 40 /(Stage.width/ini_width); 	
	_root.control_region.share._width *= (ini_width/Stage.width);				
	
	_root.control_region.zoom_full._x = _root.control_region.share._x - 18*ini_width/Stage.width; 	
	_root.control_region.zoom_full._width *= (ini_width/Stage.width);					

	_root.control_region.sound_region._x = _root.control_region.share._x - 110*ini_width/Stage.width;
	_root.control_region.sound_region._width *= (ini_width/Stage.width);						

	_root.control_region.time_region._width *= (ini_width/Stage.width);;		
	_root.control_region.replay_ins_dim._width *= (ini_width/Stage.width);;	
	_root.control_region.play_button_ins._width *= (ini_width/Stage.width);;	
	_root.control_region.pause_button_ins._width *= (ini_width/Stage.width);;		
	_root.control_region.zoom_in._width *= (ini_width/Stage.width);;			
	
	
	_root.control_region.stop_dim._x   = replay_ins._x;
	_root.control_region.stop_dim._y	  = replay_ins._y;
	_root.control_region.thanh_truot1._width=16 * ini_width/Stage.width;;

var video_width_tween:mx.transitions.Tween = new mx.transitions.Tween(_root.video_region.my_video, "_width", mx.transitions.easing.None.easeNone, video_width_start, video_width_start, 1, true);
var video_height_tween:mx.transitions.Tween = new mx.transitions.Tween(_root.video_region.my_video, "_height", mx.transitions.easing.None.easeNone, video_height_start, video_height_start, 1, true);
var video_x_tween:mx.transitions.Tween = new mx.transitions.Tween(_root.video_region.my_video, "_x", mx.transitions.easing.None.easeNone, video_x_start, video_x_start, 1, true);
var video_y_tween:mx.transitions.Tween = new mx.transitions.Tween(_root.video_region.my_video, "_y", mx.transitions.easing.None.easeNone, video_y_start, video_y_start, 1, true);
var control_tween:mx.transitions.Tween = new mx.transitions.Tween(_root.control_region, "_y", mx.transitions.easing.None.easeNone, control_end_tween_y, control_end_tween_y, 0.5, true);	
/*

var video_tween_height:mx.transitions.Tween = new mx.transitions.Tween(video_region, "_height", mx.transitions.easing.None.easeNone, video_end_tween_height, video_end_tween_height, 0.5, true);	
var video_tween_width:mx.transitions.Tween = new mx.transitions.Tween(video_region, "_width", mx.transitions.easing.None.easeNone, video_end_tween_width, video_end_tween_width, 0.5, true);	
var video_tween_y:mx.transitions.Tween = new mx.transitions.Tween(video_region, "_y", mx.transitions.easing.None.easeNone, video_end_tween_y, video_end_tween_y, 0.5, true);	
*/
_root.in_out_background._width=Stage.width;
_root.in_out_background._height=Stage.height;
_root.in_out_background.onRollOver = function()
{
	control_tween.continueTo(control_start_tween_y,0.5);
	video_height_tween.continueTo(video_height_end,0.5);	
	video_width_tween.continueTo(video_width_end,0.5);		
	video_y_tween.continueTo(video_y_end,0.5);		
	video_x_tween.continueTo(video_x_end,0.5);			
}
_root.in_out_background.onRollOut=function()
{
	control_tween.continueTo(control_end_tween_y,0.5);
	video_height_tween.continueTo(video_height_start,0.5);	
	video_width_tween.continueTo(video_width_start,0.5);		
	video_y_tween.continueTo(video_y_start,0.5);		
	video_x_tween.continueTo(video_x_start,0.5);			
}

_root.related_previous_ins.onRollOut=_root.in_out_background.onRollOut;
_root.related_previous_ins.onRollOver=_root.in_out_background.onRollOver;

_root.related_next_ins.onRollOut=_root.in_out_background.onRollOut;
_root.related_next_ins.onRollOver=_root.in_out_background.onRollOver;

_root.control_region.play_background.onRollOut=_root.in_out_background.onRollOut;
_root.control_region.play_background.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.replay_ins.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.replay_ins.onRollOut=_root.in_out_background.onRollOut;

_root.control_region.replay_ins_dim.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.replay_ins_dim.onRollOut=_root.in_out_background.onRollOut;

_root.control_region.zoom_in.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.zoom_in.onRollOut=_root.in_out_background.onRollOut;

_root.control_region.zoom_full.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.zoom_full.onRollOut=_root.in_out_background.onRollOut;

_root.my_logo.onRollOver=_root.video_region.onRollOver;
_root.my_logo.onRollOut=_root.video_region.onRollOut;

_root.control_region.share.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.share.onRollOut=_root.in_out_background.onRollOut;



_root.control_region.sound_region.volume_ins.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.sound_region.volume_ins.onRollOut=_root.in_out_background.onRollOut;

_root.control_region.sound_region.volume_on.onRollOut=_root.in_out_background.onRollOut;
_root.control_region.sound_region.volume_on.onRollOver=_root.in_out_background.onRollOver;

_root.control_region.sound_region.volume_off.onRollOut=_root.in_out_background.onRollOut;
_root.control_region.sound_region.volume_off.onRollOver=_root.in_out_background.onRollOver;

_root.control_region.loaded_bar.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.loaded_bar.onRollOut=_root.in_out_background.onRollOut;

_root.control_region.thanh_truot1.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.thanh_truot1.onRollOut=_root.in_out_background.onRollOut;

_root.control_region.played_ins.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.played_ins.onRollOut=_root.in_out_background.onRollOut;

_root.video_region.onRollOver=_root.in_out_background.onRollOver;
_root.video_region.onRollOut=_root.in_out_background.onRollOut;

_root.control_region.pause_button_ins.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.pause_button_ins.onRollOut=_root.in_out_background.onRollOut;

_root.control_region.play_button_ins.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.play_button_ins.onRollOut=_root.in_out_background.onRollOut;

_root.control_region.volume_ins.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.volume_ins.onRollOut=_root.in_out_background.onRollOut;

_root.control_region.sound_region.volume_bar1.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.sound_region.volume_bar1.onRollOut=_root.in_out_background.onRollOut;

_root.control_region.sound_region.volume_bar2.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.sound_region.volume_bar2.onRollOut=_root.in_out_background.onRollOut;

_root.control_region.sound_region.volume_bar3.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.sound_region.volume_bar3.onRollOut=_root.in_out_background.onRollOut;

_root.control_region.sound_region.volume_bar4.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.sound_region.volume_bar4.onRollOut=_root.in_out_background.onRollOut;

_root.control_region.sound_region.volume_bar5.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.sound_region.volume_bar5.onRollOut=_root.in_out_background.onRollOut;

_root.control_region.sound_region.volume_bar6.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.sound_region.volume_bar6.onRollOut=_root.in_out_background.onRollOut;

_root.control_region.sound_region.volume_bar7.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.sound_region.volume_bar7.onRollOut=_root.in_out_background.onRollOut;

_root.control_region.total_length.onRollOver=_root.in_out_background.onRollOver;
_root.control_region.total_length.onRollOut=_root.in_out_background.onRollOut;


Stage.scaleMode="noScale";
_root.control_region.total_length._width=_root.control_region.play_background._width;
pausing._visible=false;
replay_ins2._visible=false;
_root.control_region.sound_region._visible=true;
_root.replay_ins._visible=true;
_root.control_region.time_region._visible=true;
_root.control_region._visible=true;	
_root.control_region.play_button_ins._visible=false;		
_root.play_again._visible=false;




import Tooltip;
var tt:Tooltip = new Tooltip();
stop();
Stage.scaleMode="noScale";
var related_movie_ins:related_movie=new related_movie();
var fixed_width:Number=110;
var fixed_height:Number=75;
total_length._width=play_background._width;
my_related_movie0._visible=false;
bg._width=Stage.width;
bg._height=Stage.height;
bg._x=0;
bg._y=0;


pausing._visible=false;
	replay_ins2._visible=false;
	_root.sound_region._visible=true;
	_root.zoom_in._visible=true;
	_root.zoom_full._visible=true;
	_root.replay_ins._visible=true;
	_root.time_region._visible=true;
	_root.play_region._visible=true;	
	_root.play_region.play_button_ins._visible=false;		
	_root.play_again._visible=false;
//var tt:Tooltip = new Tooltip(0xECF8FF,0x000000);
_root.play_again._alpha=0;
var small:Boolean=false;
loaded_bar._x=total_length._x;
loaded_bar._y=total_length._y+1;
played_ins._x=total_length._x;
played_ins._y=total_length._y;
thanh_truot1._x=total_length._x;
thanh_truot1._y=total_length._y-2;

background_end1._visible=false;
background_end2._visible=false;
background_end3._visible=false;
related_previous_ins._visible=false;
related_next_ins._visible=false;
//if(qcd_name!=undefined&&qcd_type==flash)
//	_root.video_region.my_video._visible=false;
volume_ins._alpha=0;
var related_film_count:Number=0;
//var image_dir:String="../image/";
var end_film:Boolean=false;
var film1:Number;
var film2:Number;
var pctLoaded:Number=0;
var qcd_end:Boolean=false;
var qcc_end:Boolean=false;
var seeking:Boolean=false;
var qcc_count:Number=0;	
var qc_folder:String=qc_folder;
var qc_load_complete:Boolean=false;
var buffer_full:Boolean=false;
var can_play_time:Number=0;
var can_play_time:Number	= 0;
var qc_dau_count:Number		= 0;
var qc_cuoi_count:Number	= 0;
speaker_on._visible=true;
speaker_off._visible=false;
play_again_ins._visible=false;
share_ins._visible=false;
volume_bar._visible=false;
//var current_volume:Number=100;
var time_id2:Number;
loaded_bar._width=0;
_root.video_region.my_video._visible=true;	


System.onStatus = function(genericError) {

};
if (error_occurr == true) {
	return;
}


//var my_streaming_server:String="../video/";
film_name=my_streaming_server+film_name;
//film_name=my_streaming_server+ "FilmHQ_Disc2_2003 (15).flv";
//film_name="http://sieuthicaycanh.com/test/video/Dancing Queen-ABBA.flv";
//video_length = 221;
if(qcd_name==undefined)
{
	_root.video_region.my_video.attachVideo(stream_ns);	
	flv_mc.attachAudio(stream_ns);	
	stream_ns.play(film_name);
	var time_id2:Number = setInterval(play_film, time_interval_ms, stream_ns);										
}
else
{
	if(qcd_type=="video")
	{
		_root.video_region.my_video._visible=true;
		_root.video_region.my_video.attachVideo(start_ad_stream);	
		flv_mc.attachAudio(start_ad_stream);	
		start_ad_stream.play(qcd_name);
		var time_id1:Number = setInterval(qc_dau_func,100,stream_ns,start_ad_stream);		
	}	
	else 
	{
		_root.video_region.my_video._visible=false;		
		load_quang_cao_dau(qcd_name);	
	}
	qc_dau=true;
	var qc_count1:Number=0;	
}

_root.video_region.useHandCursor = false;



function qc_dau_func2(stream_ns_var:NetStream):Void
{
	_root.video_region.my_video._visible=false;
	qc_dau_count++;
	if(qc_dau_count>qcd_length*10)	
	{
		unloadMovie("image_mc");		
		clearInterval(time_id1);		
		_root.video_region.my_video._visible=true;		
		_root.video_region.my_video.attachVideo(stream_ns_var);
		stream_ns_var.play(_root.film_name);
		flv_mc.attachAudio(stream_ns_var);	
		qc_dau=false;
	   txt_ini_loading._visible=true;	
		time_id2 = setInterval(play_film, time_interval_ms, stream_ns);											
	}
}	
function qc_dau_func(stream_ns_var:NetStream,start_ad_stream_var:NetStream):Void
{
	qc_dau_count++;
	if((start_ad_stream_var.bytesLoaded==start_ad_stream_var.bytesTotal&&qcd_end==true)||(qc_dau_count>qcd_length*10))
	{
		clearInterval(time_id1);
		start_ad_stream_var.pause();
		_root.video_region.my_video.attachVideo(stream_ns_var);				
		_root.video_region.my_video.attachVideo(stream_ns_var);
		stream_ns_var.play(_root.film_name);
		flv_mc.attachAudio(stream_ns_var);	
		qc_dau=false;
//		test_ins.htmlText="choi phim day";
		time_id2 = setInterval(play_film, time_interval_ms, stream_ns);									
	}
}
var start_x:Number	= _root.control_region.total_length._x ;
var end_x:Number	= _root.control_region.total_length._x + _root.control_region.total_length._width - _root.control_region.thanh_truot1._width;
//var end_x:Number	= _root.control_region.total_length._x + _root.control_region.total_length._width;
var running:Boolean=false;
var pctLoaded:Number=0;
var load_completed:Boolean=false;
function play_film(my_ns:NetStream):Void 
{
   if(my_ns.bytesLoaded<my_ns.bytesTotal&&my_ns.bytesTotal>10)
   {
	   pctLoaded= Math.round(my_ns.bytesLoaded / my_ns.bytesTotal * 100);
	   _root.control_region.loaded_bar._width=Math.round(_root.control_region.total_length._width*my_ns.bytesLoaded / my_ns.bytesTotal);
   }
   else if (_root.load_completed==false&&my_ns.bytesTotal>10)
   {
   	   _root.load_completed=true;
	   _root.control_region.loaded_bar._width =  _root.control_region.total_length._width;
   }
	if (_root.is_pause == true) 
	{
		return;
	}	   		
	if (_root.slide_in_used == false) 
	{
		_root.total_time = my_ns.time;		
		second = Math.round(_root.total_time%60);
		second_string= String(Math.floor(second/10))+String((Math.round(second)%10));
		minute = Math.floor(_root.total_time/60);
		minute_string= String(Math.floor(minute/10))+String((Math.round(minute)%10));
		_root.control_region.time_region.time_playing_str.htmlText = minute_string+":"+second_string;
	}
}

//var qc_folder:String="ad/";
function qcc_call()
{
	clearInterval(time_id2);			
	if(qcc_type=="video")
	{
		_root.video_region.my_video.attachVideo(end_ad_stream);	
		flv_mc.attachAudio(end_ad_stream);	
		end_ad_stream.play(qcc_name);
		time_id3 = setInterval(qc_cuoi_func,100,end_ad_stream);					
	}	
	else 
	{
//		qcc_name="ad/"+qcc_name;			
		_root.video_region.my_video._visible=false;
		load_quang_cao_cuoi(qcc_name);
	}	
	qc_cuoi=true;
	var qcc_count:Number=0;
}
function qc_cuoi_func2(end_ad_stream_var:NetStream):Void
{
	qc_cuoi_count++;	
	if(qc_cuoi_count>qcc_length*10)	
	{
		clearInterval(time_id3);
		unloadMovie("image_mc");		
		qc_cuoi=false;
	}
}
function qc_cuoi_func(end_ad_stream_var:NetStream):Void
{
	qc_cuoi_count++;
	if((end_ad_stream_var.bytesLoaded==end_ad_stream_var.bytesTotal&&qcc_end==true)||(qc_cuoi_count>qcc_length*10))
	{
		clearInterval(time_id3);
		_root.video_region.my_video._visible=false;
		end_ad_stream_var.pause();
		qc_cuoi=false;
		//related_film_func();		
	}	
}		


my_cn.onStatus = function(infoObject)
{
	if(infoObject.code=="NetConnection.Call.Failed")
	{
		//trace("NetConnection.Call.Failed");
	}
	if(infoObject.code=="NetConnection.Connect.AppShutdown")
	{
		//trace("NetConnection.Connect.AppShutdown");
	}
	if(infoObject.code=="NetConnection.Connect.Closed")
	{
		//trace("NetConnection.Connect.Closed");
		//error_occurr=true;		
		//reconnect();
		gotoAndPlay(2);
	}
	if(infoObject.code=="NetConnection.Connect.Failed")
	{
		//trace("NetConnection.Connect.Failed");
		gotoAndPlay(2);		
	}
	if(infoObject.code=="NetConnection.Connect.InvalidApp")
	{
		//trace("NetConnection.Connect.InvalidApp");
	}
	if(infoObject.code=="NetConnection.Connect.Rejected")
	{
		//trace("NetConnection.Connect.Rejected");
	}
	if(infoObject.code=="NetConnection.Connect.Success")
	{
		//trace("NetConnection.Connect.Success");
		error_occurr=false;
	}

};
start_ad_stream.onStatus=function(infoObject1)
{
	if(infoObject1.code=="NetStream.Play.Stop")
	{
		//trace("NetStream.Play.Stop");
		_root.qcd_end=true;
	}			
}
end_ad_stream.onStatus=function(infoObject1)
{
	if(infoObject1.code=="NetStream.Play.Stop")
	{
		//trace("NetStream.Play.Stop");
		qcc_end=true;
	}			
}
var tween_started:Boolean=false;
stream_ns.onStatus=function(infoObject1)
{
	if(infoObject1.code=="NetStream.Buffer.Empty")
	{
//		trace("NetStream.Buffer.Empty");
		_root.buffer_full=false;
		if(_root.qc_dau==true||_root.qc_cuoi==true||_root.end_film==true||_root.is_pause==true||_root.slide_in_used==true)
			return;		
		_root.played_tween.stop();
		_root.run_tween.stop();
	}
	if(infoObject1.code=="NetStream.Buffer.Full")
	{
//		trace("NetStream.Buffer.Full");
		if(_root.qc_dau==true||_root.qc_cuoi==true||_root.end_film==true||_root.is_pause==true||_root.slide_in_used==true)
			return;		
		if(_root.tween_started==false)
		{
//			trace("Start");
			_root.played_tween = new mx.transitions.Tween(_root.control_region.played_ins, "_width", mx.transitions.easing.None.easeNone, start_x, end_x, _root.video_length, true);			
			_root.run_tween = new mx.transitions.Tween(_root.control_region.thanh_truot1, "_x", mx.transitions.easing.None.easeNone, start_x, end_x, _root.video_length, true);			
			_root.tween_started=true;
		}
		else if(_root.is_pause==false)
		{
			_root.played_tween.resume();
			_root.run_tween.resume();
		}

		can_play_time += stream_ns.bufferLength;
		_root.buffer_full=true;
//		txt_ini_loading._visible=false;
		seeking=false;
	}	

	if(infoObject1.code=="NetStream.Failed")
	{
		//trace("NetStream.Failed");
	}		
	if(infoObject1.code=="NetStream.Failed")
	{
		//trace("NetStream.Failed");
	}			
	
	if(infoObject1.code=="NetStream.Pause.Notify")
	{
		//trace("NetStream.Pause.Notify");
	}			
	
	if(infoObject1.code=="NetStream.Play.Complete")
	{
		//trace("NetStream.Play.Complete");
	}			
	
	if(infoObject1.code=="NetStream.Play.Failed")
	{
		//trace("NetStream.Play.Failed");
	}			
	
	if(infoObject1.code=="NetStream.Play.InsufficientBW")
	{
		//trace("NetStream.Play.InsufficientBW");
	}			
	
	if(infoObject1.code=="NetStream.Play.PublishNotify")
	{
		//trace("NetStream.Play.PublishNotify");
	}			
	
	if(infoObject1.code=="NetStream.Play.Reset")
	{
		//trace("NetStream.Play.Reset");
	}			
	
	if(infoObject1.code=="NetStream.Play.Start")
	{
		//trace("NetStream.Play.Start");
		loading._visible=false;
	}			
	
	if(infoObject1.code=="NetStream.Play.Stop")
	{
		film_stop();
	}			
	
	if(infoObject1.code=="NetStream.Play.StreamNotFound")
	{
		//trace("NetStream.Play.StreamNotFound");
	}			
	
	if(infoObject1.code=="NetStream.Play.Switch")
	{
		//trace("NetStream.Play.Switch");
	}			
	
	if(infoObject1.code=="NetStream.Play.UnpublishNotify")
	{
		//trace("NetStream.Play.UnpublishNotify");
	}			
	
	if(infoObject1.code=="NetStream.Publish.BadName")
	{
		//trace("NetStream.Publish.BadName");
	}			
	
	if(infoObject1.code=="NetStream.Publish.Idle")
	{
		//trace("NetStream.Publish.Idle");
	}			
	
	if(infoObject1.code=="NetStream.Publish.Start")
	{
		//trace("NetStream.Publish.Start");
	}			
	
	if(infoObject1.code=="NetStream.Record.Failed")
	{
		//trace("NetStream.Record.Failed");
	}			
	
	if(infoObject1.code=="NetStream.Record.NoAccess")
	{
		//trace("NetStream.Record.NoAccess");
	}			
	
	if(infoObject1.code=="NetStream.Record.Start")
	{
		//trace("NetStream.Record.Start");
	}			
	
	if(infoObject1.code=="NetStream.Record.Stop")
	{
		//trace("NetStream.Record.Stop");
	}			
	
	if(infoObject1.code=="NetStream.Seek.Failed")
	{
		//trace("NetStream.Seek.Failed");
	}			
	
	if(infoObject1.code=="NetStream.Seek.Notify")
	{
		seeking=true;
		//trace("NetStream.Seek.Notify and toatal_time"+total_time);
	}			
	
	if(infoObject1.code=="NetStream.Unpause.Notify")
	{
		//trace("NetStream.Unpause.Notify");
	}			
	
	if(infoObject1.code=="NetStream.Unpublish.Success")
	{
		//trace("NetStream.Unpublish.Success");
	}						
};

function load_quang_cao_dau(quang_cao_name:String)
{
	txt_ini_loading._visible=true;
	_root.video_region.my_video._visible=false;
	//create clips to hold your content
this.createEmptyMovieClip("hien1", 0);
//hien._width=100;
//hien._height=100;
hien1.createEmptyMovieClip("bar_mc", 1);
hien1.createEmptyMovieClip("stroke_mc", 2);
//use drawing methods to create a progress bar
with (hien1.stroke_mc) {
   lineStyle(0, 0x000000);
   moveTo(0, 0);
   lineTo(100, 0);
   lineTo(100, 10);
   lineTo(0, 10);
   lineTo(0, 0);
}
with (hien1.bar_mc) {
   beginFill(0xFF0000, 100);
   moveTo(0, 0);
   lineTo(100, 0);
   lineTo(100, 10);
   lineTo(0, 10);
   lineTo(0, 0);
   endFill();
   _xscale = 100;
   _yscale = 100;
}
hien1._x = 2;
hien1._y = 2;
// load progress
var mclListener:Object = new Object();
mclListener.onLoadStart = function(target_mc:MovieClip) {
   hien1.bar_mc._xscale = 0;
};
mclListener.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number) {
   hien1.bar_mc._xscale = Math.round(bytesLoaded/bytesTotal*100);
};
mclListener.onLoadComplete = function(target_mc:MovieClip) {
   txt_ini_loading._visible=false;	
   hien1.removeMovieClip();
   bar_mc.removeMovieClip();
   stroke_mc.removeMovieClip();   
   _root.qc_load_complete=true;
   //trace("qc_load_complete="+qc_load_complete);
	if(qc_load_complete==true)
	{
		//trace("bat dau dem thoi gian");
		time_id1 = setInterval(qc_dau_func2,100,stream_ns)
	}
	var qc_count1:Number=0;	

};
mclListener.onLoadInit = function(target_mc:MovieClip) {
   target_mc._height = 300;
   target_mc._xscale=100;
   target_mc._yscale=100;
   target_mc._width = 300;
};
//Create a clip to hold the image.
this.createEmptyMovieClip("image_mc", 0);
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
/* Load the image into the clip.
You can change the following URL to a SWF or another image file. */
image_mcl.loadClip(quang_cao_name, image_mc);
}


function load_quang_cao_cuoi(quang_cao_name:String)
{
	//create clips to hold your content
txt_ini_loading._visible=true;		
this.createEmptyMovieClip("hien2", 1);
hien2.createEmptyMovieClip("bar_mc", 2);
hien2.createEmptyMovieClip("stroke_mc", 3);
//use drawing methods to create a progress bar
with (hien2.stroke_mc) {
   lineStyle(0, 0x000000);
   moveTo(0, 0);
   lineTo(400, 0);
   lineTo(400, 10);
   lineTo(0, 10);
   lineTo(0, 0);
}
with (hien2.bar_mc) {
   beginFill(0xFF0000, 100);
   moveTo(0, 0);
   lineTo(400, 0);
   lineTo(400, 10);
   lineTo(0, 10);
   lineTo(0, 0);
   endFill();
   _xscale = 0;
}
hien2._x = 2;
hien2._y = 2;
// load progress
var mclListener:Object = new Object();
mclListener.onLoadStart = function(target_mc:MovieClip) {
   hien2.bar_mc._xscale = 0;
};
mclListener.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number) {
   hien2.bar_mc._xscale = Math.round(bytesLoaded/bytesTotal*100);
};
mclListener.onLoadComplete = function(target_mc:MovieClip) {
	txt_ini_loading._visible=false;			
   hien2.removeMovieClip();
   bar_mc.removeMovieClip();
   stroke_mc.removeMovieClip();
   _root.qc_load_complete=true;
   //trace("qc_load_complete="+qc_load_complete);
	if(qc_load_complete==true)
	{
		//trace("bat dau dem thoi gian");
		//clearInterval(time_id2);
		time_id3 = setInterval(qc_cuoi_func2,100,end_ad_stream);
	}
	var qcc_count:Number=0;	

};
mclListener.onLoadInit = function(target_mc:MovieClip) {
  target_mc._height = 300;
   target_mc._xscale=100;
   target_mc._yscale=100;
   target_mc._width = 300;

};
//Create a clip to hold the image.
this.createEmptyMovieClip("image_mc", 100);
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
/* Load the image into the clip.
You can change the following URL to a SWF or another image file. */
image_mcl.loadClip(quang_cao_name, image_mc);
}

function film_stop()
{
	//trace("STOP ispause:"+_root.is_pause);
		//test1.htmlText="stop";
		_root.load_completed=false;
		_root.slide_in_used = false;		
		if(_root.qc_dau==true||_root.qc_cuoi==true||_root.end_film==true)
			return;
		clearInterval(_root.time_id2);				
		_root.control_region.replay_ins._visible=false;
		_root.reset_video();		
		_root.pausing._visible=false;
		_root.played_tween.start();
		_root.played_tween.stop();		
		_root.run_tween.start();
		_root.run_tween.stop();		
		if(_root.mouse_moving==true&&_root.is_pause==false&&_root.button_is_pause==false)
		{
			_root.stream_ns.pause();			
		}		
		if(_root.is_pause==false)	
		{
			_root.stream_ns.pause();
		}
		_root.button_is_pause=false
		_root.mouse_moving=false;
		_root.is_pause==false;
		_root.related_film_enable = true;
		_root.total_time = 0;
		_root.control_region.thanh_truot1._x = _root.control_region.total_length._x;
		_root.control_region.played_ins._width = 0;
		_root.stream_ns.seek(0);
		_root.control_region.play_button_ins._visible = true;
		_root.control_region.pause_button_ins._visible = false;
		_root.control_region.time_region.time_playing_str.htmlText="00:00";
		_root.end_film=true;	
		if(_root.qcc_name!=undefined)
		{
			_root.qcc_call();
		}
		else
		{
			_root.video_region.my_video._visible=false;
			_root.related_film_func();		
		}					
		
}

function related_film_func() {
	my_full_mode 	= full_mode;
	id_arr 			= string_to_array(related_film_id, ',');
	name_arr 		= string_to_array(related_film_name, ',');
	display_arr 	= string_to_array(related_film_display, ',');
	length_arr 		= string_to_array(related_film_length, ',');
	author_arr 		= string_to_array(related_film_author, ',');
	image_arr 		= string_to_array(related_film_image, ',');
	star_score_arr	= string_to_array(related_film_star_score,',');	
	num_of_film = name_arr.length;
	_root.related_film_can_display = Math.floor((Stage.height-_root.control_region._height-60)/my_related_movie0._height);
//	_root.abc.htmlText=Stage.height + " " + _root.control_region._height+ " " + my_related_movie0._height + " " + related_film_can_display;
	if(num_of_film>_root.related_film_can_display)
		_root.first_related_film_position_y = Math.round((Stage.height-related_film_can_display *my_related_movie0._height -60*Stage.height/_root.ini_height)/2);
	else
		_root.first_related_film_position_y = Math.round((Stage.height-related_film_can_display *my_related_movie0._height-30*Stage.height/_root.ini_height)/2);		
	
	if(num_of_film<=0||name_arr[0]==undefined)
	{
		replay_ins2._visible=true;
		return;
	}
	if (num_of_film>0) {
//		my_related_movie0._x = -(Stage.width-ini_width)/2+first_related_film_position_x;
		my_related_movie0._y = -(Stage.height-ini_height)/2+first_related_film_position_y;		
		load_related_film(my_related_movie0,0);
	}
	if (num_of_film>1 && related_film_can_display>1) {
		duplicateMovieClip(my_related_movie0,"my_related_movie1",30);
		my_related_movie1._x=my_related_movie0._x;
		my_related_movie1._y=my_related_movie0._y+95;				
		_root.my_related_movie1.image_x = _root.my_related_movie1.hien_image_ins._x;
		_root.my_related_movie1.image_y = _root.my_related_movie1.hien_image_ins._y;		
		load_related_film(my_related_movie1,1);		
	}
	if (num_of_film>2 && related_film_can_display>2) {
		duplicateMovieClip(my_related_movie0,"my_related_movie2",31);
		my_related_movie2._x=my_related_movie1._x;
		my_related_movie2._y=my_related_movie1._y+95;						
		_root.my_related_movie2.image_x = _root.my_related_movie2.hien_image_ins._x;
		_root.my_related_movie2.image_y = _root.my_related_movie2.hien_image_ins._y;		
		load_related_film(my_related_movie2,2);		
	}	
	
	if (num_of_film>3 && related_film_can_display>3) {
		duplicateMovieClip(my_related_movie0,"my_related_movie3",32);
		my_related_movie3._x=my_related_movie2._x;
		my_related_movie3._y=my_related_movie2._y+95;						
		_root.my_related_movie3.image_x = _root.my_related_movie3.hien_image_ins._x;
		_root.my_related_movie3.image_y = _root.my_related_movie3.hien_image_ins._y;		
		load_related_film(my_related_movie3,3);		
	}	
	
	if (num_of_film>related_film_can_display) 	
	{	
		related_previous_ins._visible=true;
		related_next_ins._visible=true;		
		switch(related_film_can_display)
		{
			case 1:
			{
				related_previous_ins._y=my_related_movie0._y + 100;		
				break;
			}
			case 2:
			{
				related_previous_ins._y=my_related_movie1._y + 100;		
				break;				
			}
			case 3:
			{
				related_previous_ins._y=my_related_movie2._y + 100;		
				break;								
			}
			case 4:
			{
				related_previous_ins._y=my_related_movie3._y + 100;		
				break;								
			}
			
		}
		related_next_ins._y=related_previous_ins._y;								
		
	}
}
var film_star:Number=1;
function load_related_film(movie_name:MovieClip,movie_number:Number)
{
	_root.film_star = Math.round(2*star_score_arr[movie_number]);	
	related_movie_ins.draw_button(movie_name,movie_name.hien_image_ins,movie_name.star,display_arr[movie_number],length_arr[movie_number],_root.film_star,author_arr[movie_number],image_dir+image_arr[movie_number]);	
	_root.my_film_id = id_arr[movie_number];	
	movie_name.background_end.onRelease=function()
	{
//		ExternalInterface.call("makeRequest('in_out_get.php','?film_id="+id_arr[movie_number]+"')")		
		ExternalInterface.call("myFlash_DoFSCommand("+id_arr[movie_number]+")");		
	}

}
